package com.efounder.ui;

import android.os.Bundle;
import androidx.annotation.Nullable;
import com.google.android.material.tabs.TabLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.efounder.frame.baseui.BaseFragment;
import com.efounder.mobilecomps.R;

/**
 * 任务流程
 * 孙立鹏 on 2017/3/30 09:49
 */

public class TaskFragment extends BaseFragment {

    private ViewPager viewPager;
    private TabLayout tablayout;
    private static String[] title = {"待办任务","已办任务"};

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.orderdetail, null);


        viewPager = (ViewPager) rootView.findViewById(R.id.viewPager);
        tablayout = (TabLayout) rootView.findViewById(R.id.tabLayout);

        viewPager.setAdapter(new FragmentPagerAdapter(getActivity().getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                if(position==0){
                    return new StartTaskFragment();
                }else{

                    return new EndTaskFragment();
                }
            }

            @Override
            public int getCount() {
                return 2;
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return title[position];
            }

        });
        tablayout.setupWithViewPager(viewPager);

        return rootView;
    }
}
